<?php
class User {
	function __construct() {
	}
	
	/**
	 * _required
	 * 
	 * Check $data if it has the required fields.
	 */
	protected function _required($required, $data) {
		foreach ( $required as $field )
			if (! isset ( $data [$field] ))
				return false;
		return true;
	}
	
	function register($data = array()) {
		$required = array ('USERID', 'PASSWORD', 'NICKNAME', 'REALNAME', 'GENDER', 'BIRTH', 'ADDRESS', 'PORTRAITPATH' );
		if (! $this->_required ( $required, $data ))
			return false;
			
		$this->load->model("Users_Model", "users_model" );
		$this->users_model->addUser( $data );
	}
}